﻿using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

namespace Rampant.Muninn
{
    public class RssChannel : RssElement
    {
        private XElement _channelSource;
        private List<RssItem> _items;

        public RssChannel(XElement channelSource): base(channelSource)
        { 
            _channelSource = channelSource;
        }
        public RssElement Title { get { return GetElement("channel", "title");} }
        public RssElement Link { get { return GetElement("channel", "link"); } }
        public RssElement Description { get { return GetElement("channel", "description"); } }
        public List<RssItem> Items
        {
            get
            {
                if( _items == null )
                {
                    _items = new List<RssItem>(from i in _channelSource.Descendants("item")
                                               select new RssItem(i));
                }
                return _items;
            }
        }
    }
}
